<?php
class Users_model3 extends CI_Model {
	
	function __construct() {
		// call the Model constructor
		parent::__construct ();
		// load database class and connect to MySQL
		$this->load->database ();
	}
	
	function getAllUsers() {
		$query = $this->db->get ( 'users' );
		if ($query->num_rows () > 0) {
			// return result set as an associative array
			return $query->result_array ();
		}
	}
	
	function getUsersWhere($field, $param) {
		$this->db->where ( $field, $param );
		$query = $this->db->get ( 'users' );
		// return result set as an associative array
		return $query->result_array ();
	}
	// get 5 rows at a time
	function getUsers($row) {
		$query = $this->db->get ( 'users', 5, $row );
		if ($query->num_rows () > 0) {
			// return result set as an associative array
			return $query->result_array ();
		}
	}
	// get total number of users
	function getNumUsers() {
		return $this->db->count_all ( 'users' );
	}
	// insert new row into 'users' MySQL table using the 'set()' method
	function index() {
		$this->db->set ( 'firstname', 'Jane' );
		$this->db->set ( 'lastname', 'Smith' );
		$this->db->set ( 'email', 'jane@domain.com' );
		$this->db->insert ( 'users', $data );
	
	}
}
?>